﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using DB = HTComics.Data;
using System.Text;

namespace HTComics.Web.Admin
{
    public partial class SalesReport : System.Web.UI.Page
    {
        protected string html;

        protected void Page_Init(object sender, EventArgs e)
        {
            if (Session["IsAdmin"] == null || !Convert.ToBoolean(Session["IsAdmin"]))
            {
                Response.Redirect("Login.aspx");
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                LoadDays();
                LoadMonths();
                LoadYears();

                //Default to Today
                DateTime dtNow = DateTime.Now;
                ddlSDay.SelectedValue = (dtNow.Day-1).ToString();
                ddlSMon.SelectedValue = dtNow.Month.ToString();
                ddlSYear.SelectedValue = dtNow.Year.ToString();

                ddlEDay.SelectedValue = dtNow.Day.ToString();
                ddlEMon.SelectedValue = dtNow.Month.ToString();
                ddlEYear.SelectedValue = dtNow.Year.ToString();
            }
        }

        private void LoadDays()
        {
            for (int i = 1; i <= 31; i++)
            {
                ddlSDay.Items.Add(new ListItem(i.ToString(), i.ToString()));
                ddlEDay.Items.Add(new ListItem(i.ToString(), i.ToString()));
            }
        }

        private void LoadMonths()
        {
            string[] arrMonths = { "", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };

            for (int i = 1; i <= 12; i++)
            {
                ddlSMon.Items.Add(new ListItem(arrMonths[i], i.ToString()));
                ddlEMon.Items.Add(new ListItem(arrMonths[i], i.ToString()));
            }
        }

        private void LoadYears()
        {
            int year = 2012;

            for (int i = year; i <= DateTime.Now.Year; i++)
            {
                ddlSYear.Items.Add(new ListItem(i.ToString(), i.ToString()));
                ddlEYear.Items.Add(new ListItem(i.ToString(), i.ToString()));
            }
        }

        protected void btnRun_Click(object sender, EventArgs e)
        {
        }        
    }
}